package com.sz.biz.common.customer.service.impl;

import com.sz.biz.common.customer.entity.CusUserLoginInfo;
import com.sz.biz.common.customer.service.CustomerUserLoginInfoService;
import com.sz.common.base.dao.DaoSupport;
import com.sz.common.base.exception.BizException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * Function: TODO: ADD FUNCTION <br>
 * Author: qiankun <br>
 * Date: 2017-05-10 15:01:22
 */
@Service("CustomerUserLoginInfoService")
public class CustomerUserLoginInfoServiceImpl implements CustomerUserLoginInfoService {

    @Resource(name = "daoSupport")
    private DaoSupport dao;

    @Override
    public int updateUserLoginInfo(CusUserLoginInfo cusUserLoginInfo) throws BizException, ParseException {
        CusUserLoginInfo uliTemp = (CusUserLoginInfo) dao.findForObject("CusUserLoginInfoMapper.selectByPrimaryKey", cusUserLoginInfo.getUserName());
        if (uliTemp == null) {
            dao.save("CusUserLoginInfoMapper.insert", cusUserLoginInfo);
        } else {
            dao.save("CusUserLoginInfoMapper.updateByPrimaryKey", cusUserLoginInfo);
        }
        return 0;
    }
}
